# _*_ coding: UTF-8 _*_
# @Time     : 2021/2/24 上午 11:47
# @Author   : Li Jie
# @Site     : http://www.hzdledu.com/
# @File     : thread_test1.py
# @Software : PyCharm

import threading
import time
import os


# 实例化Thread类创建线程

def foo():
    for i in range(3):
        time.sleep(1)
        print(f'线程名:{threading.current_thread().name}')


def thread_main():
    print('--------主线程开始-------')
    threads = [threading.Thread(target=foo) for i in range(4)]  # 创建4个子线程，存入列表
    for t in threads:
        t.start()  # 子线程等待cpu调度
    for t in threads:
        t.join()  # 等待子线程结束
    print('--------主线程结束-------')


if __name__ == '__main__':
    thread_main()
